﻿Public Class FormLhAbnormalAdd
    Dim objProdLhInfo As New clsProdLhInfo
    Public prod_id As String
    Public lhj_id As String
    Public steel_seal_no As String
    Public usr As String
    Dim en As entityProdLhInfo
    Private Sub FormLhAbnormalAdd_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtDate.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True
        txtDate.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True
        txtDateFinish.Properties.VistaDisplayMode = DevExpress.Utils.DefaultBoolean.True
        txtDateFinish.Properties.VistaEditTime = DevExpress.Utils.DefaultBoolean.True
        TextBox1.Text = prod_id
        TextBox3.Text = lhj_id
        TextBox2.Text = steel_seal_no
    End Sub
    '正常
    Private Sub rbb_CheckedChanged(sender As Object, e As EventArgs) Handles rbb.CheckedChanged
        chkListassist_marker.Enabled = False
        TextBox4.Enabled = False
        txtDate.Enabled = False
        rbYes.Enabled = False
        rbNo.Enabled = False
        txtDateFinish.Enabled = False
    End Sub

    Private Sub rbbs_CheckedChanged(sender As Object, e As EventArgs) Handles rbbs.CheckedChanged
        chkListassist_marker.Enabled = True
        TextBox4.Enabled = True
        txtDate.Enabled = True
        rbYes.Enabled = True
        rbNo.Enabled = True
        txtDateFinish.Enabled = True
    End Sub
    Private Sub setEntity()
        Dim abnormal_types As String = String.Empty
        For i As Integer = 0 To chkListassist_marker.Items.Count - 1
            If chkListassist_marker.Items(i).CheckState = CheckState.Checked Then
                abnormal_types &= chkListassist_marker.Items(i).Value & ","
            End If
        Next
        If String.IsNullOrEmpty(abnormal_types) = False Then
            abnormal_types = abnormal_types.Substring(0, abnormal_types.Length - 1)
        End If
        en = New entityProdLhInfo
        With en
            .factory_id = "TS"
            .prod_id = TextBox1.Text
            .lh_result = IIf(rbb.Checked = True, rbb.Text, rbbs.Text)
            .abnormal_type = abnormal_types
            .abnormal_content = TextBox4.Text
            .show_time = txtDate.Text.Trim()
            If .lh_result.Equals("异常") Then
                .oper_result = IIf(rbYes.Checked = True, rbYes.Text, rbNo.Text)
            Else
                .oper_result = String.Empty
            End If
            .oper_finish_time = txtDateFinish.Text.Trim()
            .oper = usr
        End With

    End Sub
    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        setEntity()
        If objProdLhInfo.insert(en) <> -2 Then
            MsgBox("保存成功", vbYes, "提示")
            Close()
        Else
            MsgBox("保存失败", vbYes, "提示")
        End If
    End Sub
End Class

Public Class entityProdLhInfo
    Public factory_id As String
    Public prod_id As String
    Public lh_result As String
    Public abnormal_type As String
    Public abnormal_content As String
    Public show_time As String
    Public oper_result As String
    Public oper_finish_time As String
    Public oper As String
End Class